import { api } from '@/utils/request'
import type { MediaRecord, CreateMediaRecordRequest, UpdateMediaRecordRequest } from '@/types/media'

// 获取所有书影音记录
export const getMediaRecords = () => {
  return api.get<MediaRecord[]>('/media-records')
}

// 根据类型获取书影音记录
export const getMediaRecordsByType = (type: string) => {
  return api.get<MediaRecord[]>(`/media-records/type/${type}`)
}

// 创建书影音记录
export const createMediaRecord = (data: CreateMediaRecordRequest) => {
  return api.post<MediaRecord>('/media-records', data)
}

// 更新书影音记录
export const updateMediaRecord = (id: number, data: UpdateMediaRecordRequest) => {
  return api.put<MediaRecord>(`/media-records/${id}`, data)
}

// 删除书影音记录
export const deleteMediaRecord = (id: number) => {
  return api.delete(`/media-records/${id}`)
}

// 获取已删除的书影音记录（回收站）
export const getDeletedMediaRecords = () => {
  return api.get<MediaRecord[]>('/media-records/deleted')
}

// 恢复书影音记录
export const restoreMediaRecord = (id: number) => {
  return api.put(`/media-records/${id}/restore`)
}

// 永久删除书影音记录
export const permanentDeleteMediaRecord = (id: number) => {
  return api.delete(`/media-records/${id}/permanent`)
}
